home *** CD-ROM | disk | FTP | other *** search
- MODULE SimpleReq;
-
- (*
- Example of a custom requester from Modula-2.
-
- Created: 6/15/86 by Richard Bielak
-
- Modified:
-
- Copyright 1986, by Richard Bielak - (CIS 75716,352)
- This program may be freely distributed, but please leave my
- name in. Thanks.
-
- *)
- FROM Terminal IMPORT WriteString, WriteLn;
- FROM SYSTEM IMPORT ADR, BYTE, ADDRESS;
- FROM Intuition IMPORT
- IntuitionName, IntuitionBase, Window, WindowFlags, NewWindow,
- IDCMPFlags, IDCMPFlagsSet, WindowFlagsSet, WindowPtr, IntuitionText,
- Requester, RequesterFlagsSet, Gadget, GadgetFlagsSet, IntuiMessagePtr,
- ActivationFlagsSet, ActivationFlags, Border;
- FROM Libraries IMPORT OpenLibrary;
- FROM Windows IMPORT OpenWindow, SmartRefresh;
- FROM GraphicsLibrary IMPORT Jam2, Jam1, DrawingModeSet;
- FROM Requesters IMPORT InitRequester, Request;
-
- (* This import is needed to avoid a name conflict, the procedure *)
- (* to close the window in Window is called "CloseWindow", and *)
- (* the IDCMPFlag that says send us a close window message is *)
- (* also called "CloseWindow". *)
- IMPORT Windows;
-
- FROM Screens IMPORT WBenchScreen;
- FROM Ports IMPORT WaitPort, ReplyMsg, MessagePtr;
-
- (* Note use of a different module for GetMsg. TDI's GetMsg *)
- (* doesn't work. *)
- FROM Fixes IMPORT GetMsg;
-
-
- CONST
- IntuitionRev = 29;
- BOOLGADGET = 1H;
- REQGADGET = 1000H;
-
- VAR
- NULL : ADDRESS;
- MyWindow : NewWindow;
- MyWindowName : ARRAY [0..20] OF CHAR;
- wp : WindowPtr;
- msgptr : IntuiMessagePtr;
- succ : BOOLEAN;
- class : IDCMPFlagsSet;
-
- (* Stuff for the requester *)
- SimpleReq : Requester;
- SimpleGadget : Gadget;
- GadText,
- SimpleText1,
- SimpleText2 : IntuitionText;
- GadgetBorder,
- SimpleBorder : Border;
- GadTextStr, ReqText1, ReqText2 : ARRAY [0..30] OF CHAR;
- Pairs : ARRAY [1..10] OF INTEGER;
- GPairs : ARRAY [1..10] OF INTEGER;
-
- (* ++++++++++++++++++++++++++++++++++++++++ *)
- PROCEDURE InitWindow (VAR w : NewWindow);
- BEGIN
- MyWindowName := "Simple Requester";
- WITH w DO
- LeftEdge := 200; TopEdge := 0; Width := 320; Height := 200;
- DetailPen := BYTE (0);
- BlockPen := BYTE (1);
- Title := ADR (MyWindowName);
- Flags := WindowFlagsSet {Activate, WindowClose, WindowDrag,
- WindowDepth, NoCareRefresh} + SmartRefresh;
- IDCMPFlags :=
- IDCMPFlagsSet{CloseWindow, ReqClear,GadgetDown, GadgetUp};
- Type := CARDINAL(WBenchScreen);
- CheckMark := NULL;
- FirstGadget := NULL;
- Screen := NULL;
- BitMap := NULL;
- MinWidth := 10; MinHeight := 10;
- MaxWidth := 640; MaxHeight := 200;
- END
- END InitWindow;
-
- (* ++++++++++++++++++++++++++++++++++++++++ *)
- PROCEDURE SetUpGadget ();
- BEGIN
- (* Coordinates for border of the gadget box *)
- GPairs [1] := 0; GPairs [2] := 0;
- GPairs [3] := 61; GPairs [4] := 0;
- GPairs [5] := 61; GPairs [6] := 11;
- GPairs [7] := 0; GPairs [8] := 11;
- GPairs [9] := 0; GPairs [10] := 0;
-
- WITH GadgetBorder DO
- LeftEdge := -1; TopEdge := -1;
- FrontPen := BYTE (3); BackPen := BYTE (0);
- DrawMode := BYTE (Jam1); Count := BYTE (5);
- XY := ADR (GPairs); NextBorder := NULL;
- END;
-
- (* Text that appears in the gadget *)
- GadTextStr := "Click";
- WITH GadText DO
- FrontPen := BYTE (2); BackPen := BYTE (1);
- DrawMode := BYTE (DrawingModeSet {Jam2});
- LeftEdge := 5; TopEdge := 1;
- ITextFont := NULL; NextText := NULL;
- IText := ADR (GadTextStr);
- END;
-
- (* The gadget structure *)
- WITH SimpleGadget DO
- NextGadget := NULL;
- LeftEdge := 70; TopEdge := 45; Width := 60; Height := 10;
- Flags := GadgetFlagsSet {};
- Activation := ActivationFlagsSet {EndGadget, RelVerify};
- GadgetType := BOOLGADGET + REQGADGET;
- GadgetRender := ADR (GadgetBorder);
- SelectRender := NULL;
- GadgetText := ADR (GadText);
- MutualExclude := 0;
- SpecialInfo := NULL; GadgetID := 0; UserData := NULL
- END;
- END SetUpGadget;
-
- (* ++++++++++++++++++++++++++++++++++++++++ *)
- PROCEDURE SetUpRequester ();
- BEGIN
- (* Coordinates for border of the requester *)
- Pairs [1] := 0; Pairs [2] := 0;
- Pairs [3] := 197; Pairs [4] := 0;
- Pairs [5] := 197; Pairs [6] := 57;
- Pairs [7] := 0; Pairs [8] := 57;
- Pairs [9] := 0; Pairs [10] := 0;
-
- WITH SimpleBorder DO
- LeftEdge := 1; TopEdge := 1;
- FrontPen := BYTE (3); BackPen := BYTE (0);
- DrawMode := BYTE (Jam1); Count := BYTE (5);
- XY := ADR (Pairs); NextBorder := NULL;
- END;
-
- (* Text that appears in the gadget *)
- ReqText1 := "Example of a Requester";
- ReqText2 := " from Modula-2";
- WITH SimpleText1 DO
- FrontPen := BYTE (2); BackPen := BYTE (1);
- DrawMode := BYTE (DrawingModeSet {Jam2});
- LeftEdge := 5; TopEdge := 10;
- ITextFont := NULL; NextText := ADR (SimpleText2);
- IText := ADR (ReqText1);
- END;
- SimpleText2 := SimpleText1;
- WITH SimpleText2 DO
- LeftEdge := 5; TopEdge := 20;
- NextText := NULL; IText := ADR (ReqText2);
- END;
-
- (* InitRequestor is called to zero out the request *)
- (* structure. Must be called before putting stuff in *)
- InitRequester (SimpleReq);
-
- WITH SimpleReq DO
- LeftEdge := 20; TopEdge := 30;
- Width := 200; Height := 60;
- ReqGadget := ADR (SimpleGadget);
- ReqText := ADR (SimpleText1);
- ReqBorder := ADR (SimpleBorder);
- BackFill := BYTE (1);
- END;
- END SetUpRequester;
-
- BEGIN
- NULL := ADDRESS (0);
- (* Open intuition library *)
- IntuitionBase := OpenLibrary (IntuitionName,IntuitionRev);
- IF IntuitionBase = 0 THEN
- WriteString ("Open intuition failed"); WriteLn;
- END;
-
- (* Initialize the New window structure *)
- InitWindow (MyWindow);
- (* Set up the requester gadget *)
- SetUpGadget ();
- (* Set up the requester *)
- SetUpRequester ();
- (* Now open the window *)
- wp := OpenWindow (MyWindow);
-
- (* Display a requester *)
- succ := Request (SimpleReq, wp^);
- LOOP (* Until the window is closed *)
- (* Wait for a message from intuition *)
- msgptr := WaitPort (wp^.UserPort);
- (* After the message comes, get it and reply to it *)
- msgptr := GetMsg (wp^.UserPort);
- class := msgptr^.Class;
- (* Reply as soon as possible *)
- ReplyMsg (msgptr);
- (* Print a trace message showing what we got *)
- IF class = IDCMPFlagsSet{CloseWindow} THEN
- WriteString ("Close window");
- EXIT
- ELSIF class = IDCMPFlagsSet{ReqClear} THEN
- WriteString ("Req clear msg");
- ELSIF class = IDCMPFlagsSet{GadgetDown} THEN
- WriteString ("Gadget down");
- ELSIF class = IDCMPFlagsSet{GadgetUp} THEN
- WriteString ("Gadget up");
- END; (* IF *)
- WriteLn;
- END; (* LOOP *)
-
- Windows.CloseWindow (wp^);
- END SimpleReq.
-